import request from '@/utils/request'
import type { MenuParams, PermissionResponseData } from './type'
enum API {
  //获取全部菜单与按钮的标识数据
  ALLPERMISSTION_URL = '/admin/acl/permission',
  //给某一级菜单新增一个子菜单
  ADDMENU_URL = '/admin/acl/permission/save',
  //更新一个已有菜单
  UPDATEMENU_URL = '/admin/acl/permission/update',
  //删除已有菜单的id
  DELETEMENU_URL = '/admin/acl/permission/delete',
}
//获取全部菜单数据
export const reqAllPermission = () => {
  return request.get<any, PermissionResponseData>(API.ALLPERMISSTION_URL)
}
//添加和修改菜单的接口方法
export const reqAddOrupdateMenu = (data: MenuParams) => {
  if (data.id) {
    return request.put(API.UPDATEMENU_URL, data)
  } else {
    return request.post(API.ADDMENU_URL, data)
  }
}
//删除菜单的接口方法
export const reqRemoveMenu = (id: number) => {
  return request.delete(API.DELETEMENU_URL + id)
}
